package com.ruoyi.task.dynamicSched;

import com.ruoyi.task.dynamicSched.jdbc.MysqlScheduleTaskDao;
import com.ruoyi.task.dynamicSched.jdbc.MysqlSchedulingConfigurer;
import com.ruoyi.task.dynamicSched.json.JsonSchedulingConfigurer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SchedulingAutoConfiguration {

    @Bean
    @ConditionalOnProperty(value = "schedule.load.type", havingValue = "json")
    public JsonSchedulingConfigurer jsonSchedulingConfigurer() {
        return new JsonSchedulingConfigurer();
    }


    @Bean
    @ConditionalOnProperty(value = "schedule.load.type", havingValue = "jdbc")
    public MysqlSchedulingConfigurer mysqlSchedulingConfigurer(MysqlScheduleTaskDao mysqlScheduleTaskDao) {
        return new MysqlSchedulingConfigurer(mysqlScheduleTaskDao);
    }
}